package com.jron.cqiu.kernel.implement;

import com.jron.cqiu.kernel.util.SingletonFactory;
import com.jron.cqiu.util.ConfigurationUtil;

import java.util.Map;
import java.util.ResourceBundle;
import java.io.Serializable;

/**
 * Created by Intellij IDEA.
 *
 * @Author: Yejw
 * @Date: 2008-6-18
 * @Time: 11:52:18
 */
public class ReadProperties implements Serializable {

    private static ReadProperties rp = null;
    private Map<String, String> properties = null;
    private String bundle = null;

    public static synchronized ReadProperties instance(String bundle) {
        if (rp == null || (!rp.bundle.equals(bundle))) {
            rp = (ReadProperties) SingletonFactory.
                    createSingleton("com.jron.cqiu.kernel.implement.ReadProperties").instance();
            rp.properties = ConfigurationUtil.convertBundleToMap(ResourceBundle.getBundle(bundle));
            rp.bundle = bundle;
        }
        return rp;
    }

    public Map<String, String> getProperties() {
        return properties;
    }
}
